import Vue from 'vue'
import Vuex from 'vuex'
import {getItem, setItem} from '../utils/storage'
Vue.use(Vuex)
// token 的key
const TOKEN_KEY = 'TOUTIAO_USER'
export default new Vuex.Store({
  state: {
    // 用户登录的状态信息
    user:getItem(TOKEN_KEY),
  },
  mutations: {
    setUser(state,user){
      state.user=user
      // 防止刷新丢失备份到本地仓库中
      setItem(TOKEN_KEY,state.user)
    }
  },
  actions: {
  },
  modules: {
  }
})
